using System;
using System.Collections.Generic;
using System.Text;

namespace TVDesigner.Generator.GeneratorEntities
{
    public class TVDesignerKeyListenerGenerator
    {
        public static String DeclareClass(string package, string xletName)
        {
            StringBuilder sb = new StringBuilder();
            
            //package
            if (package != null && !package.Equals(string.Empty))
            {
                sb.Append("package ").Append(package).Append(";\n\n");
            }

            sb.Append(@"
public class TVDesignerKeyListener implements org.havi.ui.event.HKeyListener {

    public final static int KEY_RED      = 403;
    public final static int KEY_GREEN    = 404;
    public final static int KEY_YELLOW   = 405;
    public final static int KEY_BLUE     = 406;

    private ").Append(xletName).Append(@" xlet;
    
    public TVDesignerKeyListener(").Append(xletName).Append(@" xlet){
        this.xlet = xlet;
    }
    		
    public void keyTyped(java.awt.event.KeyEvent arg0) {}
    public void keyReleased(java.awt.event.KeyEvent arg0) {}
    public void keyPressed(java.awt.event.KeyEvent event) {
	    if (this.xlet.getCurrentScreen() == null) 
		    return;
        
	    this.xlet.getCurrentScreen().keyEvent(event);
        System.out.println(").Append("\"KEY_EVENT\"").Append(@");
        this.xlet.repaint();
    }
}");
            return sb.ToString();
        }
    
    }
}
